import { injectable, inject } from 'inversify';
import * as winston from 'winston';
import { ConfigService } from '../config/config.service';
import { TYPES } from '../ioc/types';

@injectable()
export class LoggerService {
  private logger: winston.Logger;

  constructor(@inject(TYPES.ConfigService) private configService: ConfigService) {
    this.logger = winston.createLogger({
      level: this.configService.getLogLevel(),
      format: winston.format.combine(
        winston.format.timestamp(),
        winston.format.json()
      ),
      transports: [
        new winston.transports.Console(),
        new winston.transports.File({ filename: 'logs/error.log', level: 'error' }),
        new winston.transports.File({ filename: 'logs/combined.log' }),
      ],
    });
  }

  info(message: string): void {
    this.logger.info(message);
  }

  error(message: string): void {
    this.logger.error(message);
  }

  warn(message: string): void {
    this.logger.warn(message);
  }
}